import request from '@/utils/request'
import qs from 'qs'
// 查询设备
export function searchDevice(groupId, limit, offset) {
  var  url = '';
  if(groupId == ''){
    url = '/web/device/search?limit=' + limit + '&offset=' + offset;
  }else{
    url = '/web/device/search?groupId= ' + groupId + '&limit=' + limit + '&offset=' + offset;
  }
  return request({
    url: url,
    method: 'get'
  })
}

// 获取设备分组信息
export function groupDevice() {
  return request({
    url: '/web/device/group',
    method: 'get'
  })
}

// 添加设备分组信息
export function addGroup(name, type) {
  return request({
    url: '/web/group/add',
    method: 'post',
    data: {
      'name': name,
      'type': type
    }
  })
}

// 删除设备分组信息
export function deleteGroup(groupId) {
  return request({
    url: '/web/device/deleteGroup?groupId=' + groupId,
    method: 'get'
  })
}

// 设备详情接口
export function deviceInfo(deviceId) {
  return request({
    url: '/web/device/info?deviceId='+ deviceId,
    method: 'get'
  })
}

// 设备分组接口
export function setGroup(data){
  return request({
    url:'/web/device/setGroup',
    method:'post',
    data:qs.stringify(data)
  })
}

// 设备命名接口
export function setName(dataList){
  return request({
    url:'/web/device/setName',
    method:'post',
    data:dataList
  })
}

// 设备互动接口
export function interaction(data){
  return request({
    url:'/web/tiktok/interaction',
    method:'post',
    data:data
  })
}

// 评论文本附件解析
export function uploadComment(file){
  return request({
    url:'/web/file/uploadComment',
    method:'post',
    data:file
  })
}
// 简单指令接口
export function command(data){
  return request({
    url:'/web/device/command',
    method:'post',
    data:data
  })
}

// 客服用户列表接口
export function userList(){
  return request({
    url:'/web/user/list',
    method:'get'
  })
}

// 指定客服接口
export function setUser(deviceImeis,groupId,userId){
  var  url = '';
  if(deviceImeis != ''){
    url = '/web/tiktok/setUser?deviceImeis=' + deviceImeis + '&userId=' + userId;
  }else{
    url = '/web/tiktok/setUser?groupId=' + groupId + '&userId=' + userId;
  }
  return request({
    url:url,
    method:'get'
  })
}

// 发布作品接口
export function publishVideo(data){
  return request({
    url:'/web/tiktok/publishVideo',
    method:'post',
    data:data
  })
}